{
swroot
  +GID
    +FILEINFO
      *.DAT
    +REGISTRY
      +1
      +2
    +ROOT1
    +ROOT2
swimage
  +gid
centericon
}
unit GIDUtils;

interface

uses
  SysUtils;

Function FileNameToGID(const aRootPath, aFileName, aGID:String):String;

implementation


Function DriveNameToGID(const FileName:String):String;
var
  Drive:String;
begin
  Drive:= ExtractFileDrive(FileName) ;
  if SameText(Drive, 'C:') then Result := 'ROOT1'
  else if SameText(Drive, 'D:') then Result := 'ROOT2'
  else 
    Raise Exception.Create( 'DriveNameToGID Exception. Not Supported Drive Type ');

end;

Function FileNameToGID(const aRootPath, aFileName, aGID:String):String;
var
  Drive,FileName:String;
begin
  Drive:= ExtractFileDrive(aFileName) ;

  FileName :=  ExcludeTrailingBackslash( aRootPath );
  FileName := FileName + '\' + aGid + '\';
  FileName := FileName + DriveNameToGID( aFileName );

  FileName := FileName + '\' + Copy(aFileName,4, Length(aFileName) - 3);
  Result := FileName;
end;

end.
